package com.situ.service.impl;


import com.situ.bean.Category;

import com.situ.dao.CategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminCategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    // 获取所有商品种类
    public List<Category> getAllCategories() {
        return categoryMapper.getAllCategories();
    }

    // 根据ID获取商品种类
    public Category getCategoryById(int id) {
        return categoryMapper.getCategoryById(id);
    }

    // 添加商品种类
    public void addCategory(Category category) {
        categoryMapper.addCategory(category);
    }

    // 更新商品种类
    public void updateCategory(Category category) {
        categoryMapper.updateCategory(category);
    }

    // 删除商品种类
    public void deleteCategory(int id) {
        categoryMapper.deleteCategory(id);
    }

    // 获取所有父级分类
    public List<Category> getAllParentCategories() {
        return categoryMapper.getAllParentCategories();
    }

    // 根据父级ID获取子分类
    public List<Category> getCategoriesByParentId(int pid) {
        return categoryMapper.getCategoriesByParentId(pid);
    }
}